<template>
  <div class="pages prepaid">
    <div class="pageLevel" v-if="!sub">
      <div class="head">
        <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
          <el-tab-pane v-if="setRole('未付查看')" label="未付" name="1">
            <!-- 搜索框 -->
            <div class="tableSearch">
              <el-form label-width="100px" class="demo-ruleForm" size="small">
                <el-form-item label="单据日期：" style="margin-left:-12px">
                  <el-date-picker :clearable="false" format="yyyy-MM-dd" value-format="yyyy-MM-dd" v-model="selectdata.bill" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                  </el-date-picker>
                </el-form-item>
                <el-form-item label-width="100px" label="付款类型：" style="margin-left:0px">
                  <el-select v-model="selectdata.selects" size="small">
                    <el-option label="全部" value=""></el-option>
                    <el-option label="采购付款" value="1"></el-option>
                    <el-option label="退货付款" value="2"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="企业名称：" label-width="100px" style="margin-left:0px">
                  <el-input class="input" v-model="selectdata.keyword" size="small" placeholder="请输入企业名称"></el-input>
                </el-form-item>
                <el-form-item label="" prop="wxser" class="wxelForm" label-width="25px">
                  <el-button type="primary" @click="search()" size="mini">搜索</el-button>
                </el-form-item>
              </el-form>
            </div>
            <!-- 表格 -->
            <div class="tableMain">
              <el-table :data="tableData" border style="width: 100%">
                <el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
                <el-table-column prop="purchaseNo" label="订单号" align="center">
                </el-table-column>
                <el-table-column prop="payeeName" label="企业名称" align="center">
                </el-table-column>
                <el-table-column prop="orderTime" label="单据日期" align="center" :formatter="trunTime">
                </el-table-column>
                <el-table-column prop="paymentType" label="付款类型" align="center" :formatter="paymentType">
                </el-table-column>
                <el-table-column prop="orderPrice" label="总金额" align="center">
                </el-table-column>
                <el-table-column prop="paymentStatus" label="付款状态" align="center" :formatter="paymentStatus">
                </el-table-column>
                <el-table-column prop="paidPrice" label="付款金额" align="center">
                </el-table-column>
                <el-table-column label="操作" width="180" align="center">
                  <template slot-scope="scope">
                    <el-button size="small" v-if="scope.row.remsPrice!='0.00'&&setRole('未付支付')" @click="recharge(scope.row.orderNo,scope.row.remainingPrice,scope.row.payeeId,scope.row.payerId,scope.row.paymentType,scope.row.orderType)" type="text" class="addDetail">付款</el-button>
                    <el-button size="small" @click="withdraw(scope.row.orderNo)" v-if="scope.row.cannelFlag==1&&setRole('未付撤回')" type="text" class="addDetail">撤回</el-button>
                    <el-button size="small" v-if="setRole('未付详情')" @click="detailed('/financial-center/receivable-finance/finance-copeWith/details-payable',scope.row.id,scope.row.paymentStatus)" type="text" class="addDetail">详情</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div class="pageblock">
                <el-button size="small" type="primary" class="topage" @click="toPage">确定</el-button>
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10,20,50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="revoke.total">
                </el-pagination>
              </div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="部分支付" v-if="setRole('部分支付查看')" name="2">
            <!-- 搜索框 -->
            <div class="tableSearch">
              <el-form label-width="100px" class="demo-ruleForm" size="small">
                <el-row>
                  <el-col style="width:470px;">
                    <el-form-item label="单据日期：" style="margin-left:10px">
                      <el-date-picker :clearable="false" format="yyyy-MM-dd" value-format="yyyy-MM-dd" v-model="selectdata.bill" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col style="width:270px;">
                    <el-form-item label-width="100px" label="付款类型：" style="margin-left:10px">
                      <el-select v-model="selectdata.selects" size="small">
                        <el-option label="全部" value=""></el-option>
                        <el-option label="采购付款" value="1"></el-option>
                        <el-option label="退货付款" value="2"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col style="width:470px;">
                    <el-form-item label="赊销日期：" style="margin-left:10px">
                      <el-date-picker format="yyyy-MM-dd" value-format="yyyy-MM-dd" v-model="selectdata.credit" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col style="width:300px;">
                    <el-form-item label="企业名称：" label-width="90px" style="margin-left:20px">
                      <el-input class="input input-left" v-model="selectdata.keyword" size="small" placeholder="请输入企业名称"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col style="width:300px;">
                    <el-form-item label="" prop="wxser" class="wxelForm" label-width="25px">
                      <el-button type="primary" @click="search()" size="mini">搜索</el-button>
                    </el-form-item>
                    <el-form-item label="" label-width="35px">
                      <el-button type="primary" icon="el-icon-download" v-if="setRole('部分支付导出')" size="mini" @click="download('部分支付导出.xlsx')" class="Button">导出</el-button>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </div>
            <div class="total-income">
              <div class="all-income">
                剩余金额 :
                <span>{{totalRemainingPrice}}</span> 元
              </div>
            </div>
            <!-- 表格 -->
            <div class="tableMain">
              <el-table :data="tableData" border style="width: 100%">
                <el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
                <el-table-column prop="purchaseNo" label="订单号" align="center">
                </el-table-column>
                <el-table-column prop="payeeName" label="企业名称" align="center">
                </el-table-column>
                <el-table-column prop="orderTime" label="单据日期" align="center" width="110" :formatter="trunTime">
                </el-table-column>
                <el-table-column prop="paymentType" label="付款类型" align="center" :formatter="paymentType">
                </el-table-column>
                <el-table-column prop="orderPrice" label="总金额" align="center">
                </el-table-column>
                <el-table-column prop="paidPrice" label="已付金额" align="center">
                </el-table-column>
                <el-table-column prop="lastPayType" label="支付方式" align="center" :formatter="lastPayType">
                </el-table-column>
                <el-table-column prop="lastPayTime" label="支付时间" align="center" width="110" :formatter="trunTimes">
                </el-table-column>
                <el-table-column prop="remainingPrice" label="剩余金额" align="center">
                </el-table-column>
                <el-table-column prop="creditTime" label="赊销日期" align="center" width="110" :formatter="trunTime">
                </el-table-column>
                <el-table-column prop="creditPrice" label="赊销金额" align="center">
                </el-table-column>
                <el-table-column label="操作" width="180" align="center">
                  <template slot-scope="scope">
                    <el-button size="small" v-if="scope.row.remsPrice!='0.00'&&setRole('部分支付支付')" @click="recharge(scope.row.orderNo,scope.row.remainingPrice,scope.row.payeeId,scope.row.payerId,scope.row.paymentType,scope.row.orderType)" type="text" class="addDetail">付款</el-button>
                    <el-button size="small" @click="withdraw(scope.row.orderNo)" v-if="scope.row.cannelFlag==1&&setRole('部分支付撤回')" type="text" class="addDetail">撤回</el-button>
                    <el-button size="small" v-if="setRole('部分支付详情')" @click="detailed('/financial-center/receivable-finance/finance-copeWith/details-payable',scope.row.id,scope.row.paymentStatus)" type="text" class="addDetail">详情</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div class="pageblock">
                <el-button size="small" type="primary" class="topage" @click="toPage">确定</el-button>
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10,20,50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="revoke.total">
                </el-pagination>
              </div>

            </div>
          </el-tab-pane>
          <el-tab-pane label="已付" v-if="setRole('已付查看')" name="3">
            <!-- 搜索框 -->
            <div class="tableSearch">
              <el-form label-width="100px" class="demo-ruleForm" size="small">
                <el-row>
                  <el-col style="width:470px;">
                    <el-form-item label="单据日期：" style="margin-left:10px">
                      <el-date-picker :clearable="false" format="yyyy-MM-dd" value-format="yyyy-MM-dd" v-model="selectdata.bill" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col style="width:222px;">
                    <el-form-item label-width="100px" label="付款类型：" style="margin-left:10px">
                      <el-select v-model="selectdata.selects" size="small">
                        <el-option label="全部" value=""></el-option>
                        <el-option label="采购付款" value="1"></el-option>
                        <el-option label="退货付款" value="2"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col style="width:300px;">
                    <el-form-item label="企业名称：" label-width="100px" style="margin-left:20px">
                      <el-input class="input" v-model="selectdata.keyword" size="small" placeholder="请输入企业名称"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col style="width:470px;">
                    <el-form-item label="支付时间：" style="margin-left:10px;">
                      <el-date-picker format="yyyy-MM-dd" value-format="yyyy-MM-dd" v-model="selectdata.topal" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col style="width:222px;">
                    <el-form-item label-width="100px" label="是否多笔：" style="margin-left:10px">
                      <el-select v-model="selectdata.isMultiple" size="small">
                        <el-option label="全部" value=""></el-option>
                        <el-option label="是" value="1"></el-option>
                        <el-option label="否" value="0"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-form-item label="" prop="wxser" class="wxelForm" label-width="95px">
                    <el-button type="primary" @click="search()" size="mini">搜索</el-button>
                  </el-form-item>
                  <el-form-item label="" label-width="55px">
                    <el-button type="primary" icon="el-icon-download" size="mini" v-if="setRole('已付导出')" @click="download('已付导出.xlsx')" class="Button">导出</el-button>
                  </el-form-item>
                </el-row>
              </el-form>
            </div>
            <!-- 表格 -->
            <div class="tableMain">
              <el-table :data="tableData" border style="width: 100%">
                <el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
                <el-table-column prop="purchaseNo" label="订单号" align="center">
                </el-table-column>
                <el-table-column prop="payeeName" label="企业名称" align="center">
                </el-table-column>
                <el-table-column prop="orderTime" label="单据日期" align="center" width="110" :formatter="trunTime">
                </el-table-column>
                <el-table-column prop="paymentType" label="付款类型" align="center" :formatter="paymentType">
                </el-table-column>
                <el-table-column prop="orderPrice" label="总金额" align="center">
                </el-table-column>
                <el-table-column prop="lastPayTime" label="支付时间" align="center" width="110" :formatter="trunTimes">
                </el-table-column>
                <el-table-column prop="isMultiple" label="是否多笔支付" align="center" :formatter="isMultiple">
                </el-table-column>
                <el-table-column label="操作" width="180" align="center">
                  <template slot-scope="scope">
                    <el-button size="small" v-if="setRole('已付详情')" @click="detailed('/financial-center/receivable-finance/finance-copeWith/details-payable',scope.row.id,scope.row.paymentStatus)" type="text" class="addDetail">详情</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div class="pageblock">
                <el-button size="small" type="primary" class="topage" @click="toPage">确定</el-button>
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10,20,50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="revoke.total">
                </el-pagination>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <div class="pageLevel" v-else>
      <router-view></router-view>
    </div>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" class="addshopname" title="付款" :visible.sync="dialogFormVisible" width="610px">
      <el-form :model="form" :rules="rules" ref="form" center>
        <el-form-item label="付款方式：" :label-width="formLabelWidth">
          <el-select class="selecttype" size="small" v-model="form.tradeType" placeholder="付款方式">
            <el-option label="在线支付" value="2" v-if="orderType=='0'"></el-option>
            <el-option label="线下支付" value="1"></el-option>
            <el-option label="预付款支付" value="3" v-if="prePay==1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="预付款余额：" :label-width="formLabelWidth" v-if="form.tradeType=='3'">
          <span>{{orderPrice}} 元</span>
        </el-form-item>
        <el-form-item label="付款时间：" :label-width="formLabelWidth" v-if="form.tradeType=='1'">
          <el-date-picker type="date" v-model="form.deliveryDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择付款时间"></el-date-picker>
        </el-form-item>
        <el-form-item label="付款金额：" :label-width="formLabelWidth" v-if="form.tradeType=='1'">
          <sd-input :val.sync='form.money' placeholder="请输入付款金额" style="width:120px;float:left; "></sd-input>
          <span style='margin-left: 10px'>元</span>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" center>
        <el-button @click="cancel()">取 消</el-button>
        <el-button type="primary" @click="orderPay()">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" class="addshopname" title="选择撤回订单" :visible.sync="dialogFormWithdraw" width="610px">
      <div v-for="(item,index) in  PayList" :key='index' class="box">
        <el-checkbox-group v-model="checkList">
          <el-checkbox :label="item.payNo">
            <div class="box-revoke">支付时间： <span>{{item.payTime}}</span> </div>
            <div class="box-gode">支付金额：<span>{{item.price}}</span> </div>
          </el-checkbox>
        </el-checkbox-group>
      </div>
      <div slot="footer" class="dialog-footer" center>
        <el-button @click="dialogFormWithdraw = false">取 消</el-button>
        <el-button type="primary" @click="receiptWithdraw">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { mapState } from "vuex";
import {
  findByListing,
  orderPay,
  receiptWithdraw,
  findByPayList,
  preAccountList,
  findByListExport,
  payTypeList
} from "@/api";
var fileDownload = require("js-file-download");
import util from "@/util";
import s from "@/util/state";
import sdInput from "@/components/SdInput";
export default {
  components: { sdInput },
  computed: mapState(["merchantId", "sub", "power"]),
  data() {
    return {
      orderType: "0",
      Data: {},
      totalRemainingPrice: "",
      prePay: "",
      zjPay: "",
      rules: {},
      // formData: {
      orderNo: "",
      orderPrice: "",
      remainingPrice: "",
      // },
      paymentSta: "1",
      timer: "",
      form: {
        operPrice: "",
        tradeType: "2"
      },
      formPart: {
        operPrice: "",
        tradeType: "2"
      },
      gold: "",
      formLabelWidth: "120px",
      dialogFormVisible: false,
      dialogFormWithdraw: false,
      pageSize: 10,
      total: 0,
      currentPage: 1,
      activeName: "1",
      selectdata: {
        selects: "",
        credit: [],
        bill: [],
        isMultiple: "",
        keyword: "",
        topal: []
      },
      selectdatas: {
        selects: "",
        credit: [],
        bill: [],
        isMultiple: "",
        topal: [],
        keyword: ""
      },
      revoke: { total: 0 },
      checkList: [],
      PayList: [],
      tableDataPart: [],
      tableData: [],
      options: [],
      value: []
    };
  },
  created() {
    this.getTime();
    this.powers();
  },
  mounted() {
    this.getdata(10, 1);
  },
  watch: {
    sub: {
      handler: function(val, oldVal) {
        if (oldVal != null && val == false) {
          this.getdata(this.pageSize, this.currentPage);
        }
      },
      deep: true
    }
  },
  methods: {
    cancel() {
      this.dialogFormVisible = false;
    },
    powers() {
      //判断权限显示tab
      if (this.setRole("未付查看") == true) {
        this.activeName = "1";
      } else if (this.setRole("部分支付查看") == true) {
        this.activeName = "2";
      } else if (this.setRole("已付查看") == true) {
        this.activeName = "3";
      }
    },
    setRole(key) {
      return util.selectTitle(this.power, key);
    },
    getdatetime(now, l = "-", m = ":") {
      now = parseInt(now);
      now = new Date(now);
      let year = now.getFullYear();
      let month = now.getMonth() + 1;
      let date = now.getDate();
      let hour = now.getHours();
      let minute = now.getMinutes();
      // let seconds = now.getSeconds()
      if (month < 10) {
        month = "0" + month;
      }
      if (date < 10) {
        date = "0" + date;
      }
      if (hour < 10) {
        hour = "0" + hour;
      }
      if (minute < 10) {
        minute = "0" + minute;
      }
      return year + l + month + l + date;
    },
    getTime() {
      //---------------默认当前时间
      let date = new Date();
      let y = date.getFullYear();
      let m = date.getMonth() + 1;
      let d = date.getDate();
      if (m >= 1 && m <= 9) {
        m = "0" + m;
      }
      if (d >= 1 && d <= 9) {
        d = "0" + d;
      }
      let time = y + "-" + m + "-" + d;
      //  this.selectdata.bill[0]= time;
      this.$set(this.selectdata.bill, 0, time);
      this.$set(this.selectdata.bill, 1, time);
    },
    paymentStatus: s.paymentStatus,
    paymentType: s.paymentType,
    lastPayType: s.lastPayType,
    isMultiple: s.isMultiple,
    findByPayList() {
      let postdata = {
        userId: this.merchantId,
        type: 2,
        orderNo: this.orderNo
      };
      findByPayList(postdata).then(res => {
        this.PayList = res.data;
        for (let i = 0; i < res.data.length; i++) {
          this.PayList[i].payTime = this.getdatetime(res.data[i].payTime);
        }
      });
    },
    orderPay() {
      console.log(this.form.deliveryDate);
      if (
        this.form.tradeType == "1" &&
        (this.form.deliveryDate === null ||
          this.form.deliveryDate == "" ||
          this.form.deliveryDate === undefined)
      ) {
        this.$message({
          message: "请输选择付款时间"
        });
        return false;
      }
      if (
        this.form.tradeType == "1" &&
        (this.form.money <= 0 ||
          this.form.money == "" ||
          this.form.money === undefined)
      ) {
        this.$message({
          message: "付款金额应大于0"
        });
        return false;
      }
      let postdata = {
        orderNo: this.orderNo,
        payType: this.form.tradeType,
        price: this.form.money,
        payTime: this.form.deliveryDate
      };
      orderPay(postdata).then(res => {
        if (res.code == 200) {
          this.$message({
            showClose: true,
            message: "支付成功",
            type: "success"
          });
          this.orderNo = "";
          this.dialogFormVisible = false;
          this.getdata(10, 1);
        }
      });
    },
    receiptWithdraw() {
      if (this.checkList.length == 0) {
        this.$message({
          message: "请选择要撤回的数据"
        });
        return false;
      }
      let postdata = {
        payNo: this.checkList
      };
      receiptWithdraw(postdata).then(res => {
        if (res.code == 200) {
          this.$message({
            showClose: true,
            message: "撤回成功",
            type: "success"
          });
          this.dialogFormWithdraw = false;
          this.getdata(10, 1);
        }
        this.checkList = [];
        this.findByPayList();
      });
    },
    search() {
      this.getdata(this.pageSize, this.currentPage);
    },
    trunTime(row, column, cellValue) {
      return util.foryear(cellValue);
    },
    trunTimes(row, column, cellValue) {
      if (row.lastPayType == 1) {
        //线下支付 时间格式
        return util.foryear(cellValue);
      } else {
        return util.foryear(cellValue) + " " + util.fortime(cellValue);
      }
    },
    retreat() {
      // console.log(this.checkList);
    },
    detailed(name, id, type) {
      util.routerTo(name, {
        type: type,
        id: id
      });
    },
    recharge(
      orderNo,
      remainingPrice,
      payeeId,
      payerId,
      paymentType,
      orderType
    ) {
      this.form.tradeType = "2";
      this.orderType = orderType;
      if (this.orderType == "1") {
        this.$set(this.form, "tradeType", "1");
      }
      this.$delete(this.form, "deliveryDate");
      this.form.deliveryDate === undefined;
      this.form.money = 0;
      let postdata = {
        payeeId: payeeId,
        payerId: payerId
      };
      let postdatas = {
        payeeId: payeeId,
        payerId: payerId,
        paymentType: paymentType
      };
      let postdataty = {
        payeeId: payerId,
        payerId: payeeId
      };
      if (paymentType == "2") {
        postdata = postdataty;
        console.log(5555);
      }
      preAccountList(postdata).then(res => {
        if (res.data.length > 0) {
          this.orderPrice = res.data[0].price;
        }
      });
      payTypeList(postdatas).then(res => {
        this.prePay = res.data.prePay;
        this.zjPay = res.data.zjPay;
      });
      this.orderNo = orderNo;
      this.remainingPrice = remainingPrice;
      this.dialogFormVisible = true;
    },
    withdraw(orderNo) {
      this.orderNo = orderNo;
      this.checkList = [];
      this.findByPayList();
      this.dialogFormWithdraw = true;
    },
    handleClick(tab, event) {
      this.selectdata = this.selectdatas;
      this.selectdata.isMultiple = "";
      this.selectdata.selects = "";
      this.selectdata.keyword = "";
      this.selectdata.credit = ["", ""];
      this.selectdata.topal = ["", ""];
      this.getTime();
      this.paymentSta = tab.name;
      this.pageSize = 10;
      this.currentPage = 1;
      this.getdata(10, 1);
    },
    getdata(pageSize, pageNum) {
      if (!this.value) {
        this.value = ["", ""];
      }
      if (!this.selectdata.credit) {
        this.selectdata.credit = ["", ""];
      }
      if (!this.selectdata.topal) {
        this.selectdata.topal = ["", ""];
      }
      this.Data = {
        userId: this.merchantId,
        paymentType: this.selectdata.selects,
        paymentStatus: this.activeName,
        name: this.selectdata.keyword,
        isMultiple: this.selectdata.isMultiple,
        pageNo: pageNum,
        pageSize: pageSize,
        startTime: this.selectdata.bill[0],
        endTime: this.selectdata.bill[1],
        creditStartTime: this.selectdata.credit[0],
        creditEndTime: this.selectdata.credit[1],
        payStartTime: this.selectdata.topal[0],
        payEndTime: this.selectdata.topal[1],
        type: 2
      };
      findByListing(this.Data).then(res => {
        this.tableData = res.data.list;
        this.totalRemainingPrice = res.data.totalRemainingPrice;
        for (let i = 0; i < this.tableData.length; i++) {
          this.tableData[i].remsPrice = (
            parseFloat(this.tableData[i].orderPrice) -
            parseFloat(this.tableData[i].paidPrice) -
            parseFloat(this.tableData[i].unconfirmedPrice)
          ).toFixed(2);
          // console.log(typeof this.tableData[i].remsPrice);
          // console.log(this.tableData[i].remsPrice);
          if (this.tableData[i].paymentType == 2) {
            // 取销售退货单号
            this.tableData[i].purchaseNo = this.tableData[i].salesNo;
          }
          if (this.tableData[i].paymentStatus == 1) {
            this.tableData[i].paidPrice = this.tableData[i].unconfirmedPrice; //订单状态待确 付款金额为待确认金额
          }
          if (this.tableData[i].paymentStatus == 0) {
            this.tableData[i].paidPrice = ""; //订单状态未付 付款金额为空
          }
        }
        this.total = res.data.total;
        this.$set(this.revoke, "total", res.data.total);
      });
    },
    toPage() {
      this.getdata(this.pageSize, 1);
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.getdata(val, this.currentPage);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getdata(this.pageSize, val);
    },
    download(fileName) {
      if (!this.value) {
        this.value = ["", ""];
      }
      if (!this.selectdata.credit) {
        this.selectdata.credit = ["", ""];
      }
      if (!this.selectdata.topal) {
        this.selectdata.topal = ["", ""];
      }
      let datas = {
        userId: this.merchantId,
        paymentType: this.selectdata.selects,
        paymentStatus: this.paymentSta,
        name: this.selectdata.keyword,
        isMultiple: this.selectdata.isMultiple,
        pageNo: this.currentPage,
        pageSize: this.pageSize,
        startTime: this.selectdata.bill[0],
        endTime: this.selectdata.bill[1],
        creditStartTime: this.selectdata.credit[0],
        creditEndTime: this.selectdata.credit[1],
        payStartTime: this.selectdata.topal[0],
        payEndTime: this.selectdata.topal[1],
        type: 2
      };
      if (this.tableData.length == 0) {
        this.$message({
          type: "error",
          message: "数据为空不能导出"
        });
      } else {
        findByListExport(datas)
          .then(res => {
            if (res.data == undefined) {
              fileDownload(res, fileName);
            } else {
              this.$message(res.data.msg);
            }
          })
          .catch(e => {});
      }
    }
  }
};
</script>
<style scoped>
.head {
  margin-top: 10px;
  /* background: #fff; */
}
.box-revoke {
  position: absolute;
  left: 30px;
  top: 0px;
}
.box-gode {
  position: absolute;
  left: 200px;
  top: 0px;
}
.box {
  width: 500px;
  height: 38px;
  margin-left: 40px;
  position: relative;
}
.prepaid .total-income {
  color: #606266;
  width: 100%;
  line-height: 55px;
  margin: 0px 0px 10px 0px;
  border-bottom: 1px solid #eee;
  font-weight: bold;
}
.prepaid .total-income .all-income {
  margin-left: 30px;
}
.prepaid .total-income .all-income span {
  margin-left: 10px;
}
</style>
